using DG.Tweening;
using UnityEngine;

namespace Share
{
    public class Shark : MonoBehaviour
    {
        private Vector3 m_OriginalScale;
        private Sequence m_ScaleSequence;
        [SerializeField]
        float m_fScaleMax = 0.95f;
        [SerializeField]
        float m_fScaleTime = 0.15f;
        void Start()
        {
            m_OriginalScale = transform.localScale;
        }

        public void PlayScaleAnimation()
        {
            // Kill and restart any existing animation
            if (m_ScaleSequence != null)
            {
                m_ScaleSequence.Kill();
            }
            transform.localScale = m_OriginalScale;

            // Create new sequence
            m_ScaleSequence = DOTween.Sequence();

            // Shrink to 95% height (0.15s)
            m_ScaleSequence.Append(
                transform.DOScaleY(m_OriginalScale.y * m_fScaleMax, m_fScaleTime)
            );

            // Return to original size (0.15s)
            m_ScaleSequence.Append(
                transform.DOScaleY(m_OriginalScale.y, m_fScaleTime)
            );

            m_ScaleSequence.Play();
        }
    }
}
